package com.joysuch.wwyt.core.repository;

import com.joysuch.wwyt.core.entity.BaseEvaluationIndicatorsContentDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BaseEvaluationIndicatorsContentDetailDao extends JpaRepository<BaseEvaluationIndicatorsContentDetail, Long>{

    @Query(value = "SELECT ID FROM `wwyt_base_evaluation_indicators_content_detail` WHERE CODE =?1 and EIC_ID=?2", nativeQuery = true)
    Long findByCodeAndEicId(String code, Long eicId);

    List<BaseEvaluationIndicatorsContentDetail> findByEicId(Long id);

    @Query(value = "SELECT ID FROM `wwyt_base_evaluation_indicators_content_detail` WHERE CODE =?1 and EIC_ID=?2", nativeQuery = true)
    List<BaseEvaluationIndicatorsContentDetail> findByEicIdAndType(Long id, String type);

    @Query(value = "SELECT  distinct OPTION_TYPE FROM `wwyt_base_evaluation_indicators_content` WHERE EIC_ID =?1 ", nativeQuery = true)
    List<String> findTypeByEicId(Long id);

    @Query(value = "SELECT ID FROM `wwyt_base_evaluation_indicators_content_detail` WHERE CODE =?1", nativeQuery = true)
    List<Long> findIdBytype(String deleteType);
}
